11. What Belongs in the GameViewModel?

L5 14 Exercise Step 2- Populate The GameViewModel- SC

What Goes in the ViewModel?

What should be moved to the ViewModel? Keep in mind:

  • The ViewModel is a stable place to store the data to display in the associated UI controller.
  • The Fragment draws the data on screen and captures input events. It should not decide what to display on screen or process what happens during an input event.
  • The ViewModel never contains references to activities, fragments, or views.
SOLUTION:
  • The score and word field.
  • The wordList field.
  • The resetList and nextWord methods.